Ext.onReady(function(){
    
    var showResult = function(btn){
        YAHOO.printf('You clicked the {0} button.', btn);
    };
    
    var showResultText = function(btn, text){
        YAHOO.printf('You clicked the {0} button and entered the text "{1}".', btn, text);
    };
    
    getEl('mb1').on('click', function(){
       Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult); 
    });
    
    getEl('mb2').on('click', function(){
       Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText); 
    });
    
    getEl('mb3').on('click', function(){
       Ext.MessageBox.show({
           title: 'Address',
           msg: 'Please enter your address:',
           width:300,
           buttons: Ext.MessageBox.OKCANCEL,
           multiline: true,
           fn: showResultText
       }); 
    });
    
    getEl('mb4').on('click', function(){
       Ext.MessageBox.show({
           title:'Save Changes?',
           msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
           buttons: Ext.MessageBox.YESNOCANCEL,
           fn: showResult
       }); 
    });
    
    getEl('mb5').on('click', function(){
       Ext.MessageBox.progress('Please wait...', 'This dialog will hide after 5 seconds...');
       setTimeout(Ext.MessageBox.hide, 5000);
    });
    
    getEl('mb6').on('click', function(){
       Ext.MessageBox.show({
           title: 'Please wait...',
           msg: 'Initializing...',
           width:240,
           progress:true,
           closable:false
       });
       
       // this hideous block creates the bogus progress
       var f = function(v){
            return function(){
                if(v == 11){
                    Ext.MessageBox.hide();
                }else{
                    Ext.MessageBox.updateProgress(v/10, 'Loading item ' + v + ' of 10...');
                }
           };
       }
       for(var i = 1; i < 12; i++){
           setTimeout(f(i), i*1000);
       }
    });
    
    getEl('mb7').on('click', function(){
       Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult); 
    });
    
    
});

